/*    */ package org.poebot.hal;
/*    */ 
/*    */ import java.util.ArrayList;
/*    */ import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
/*    */ 
/*    */ public class ChatTextArea extends JTextArea
/*    */ {
/*    */   private static final long serialVersionUID = 4476388113256874054L;
/* 50 */   ArrayList<String> chatBuffer = null;
/*    */   private final int bufferSize;
/*    */ 
/*    */   public ChatTextArea(int bufferSize)
/*    */   {
/* 15 */     this.bufferSize = bufferSize;
/* 16 */     this.chatBuffer = new ArrayList<String>(bufferSize);
/*    */   }
/*    */ 
/*    */   public void addLine(String line)
/*    */   {
/* 21 */     if (this.chatBuffer.size() >= this.bufferSize)
/* 22 */       this.chatBuffer.remove(0);
/* 23 */     this.chatBuffer.add(line);
/* 24 */     SwingUtilities.invokeLater(
/* 25 */       new Runnable()
/*    */     {
/*    */       public void run() {
/* 28 */         ChatTextArea.this.buildBufferText();
/* 29 */         ChatTextArea.this.updateUI();
/*    */       }
/*    */     });
/*    */   }
/*    */ 
/*    */   public synchronized void buildBufferText()
/*    */   {
/* 37 */     if (this.chatBuffer == null)
/*    */     {
/* 39 */       return;
/*    */     }
/* 41 */     String text = "";
/* 42 */     for (int i = 0; i < this.chatBuffer.size(); i++)
/*    */     {
/* 44 */       String line = (String)this.chatBuffer.get(i);
/* 45 */       text = text.concat(line + "\n");
/*    */     }
/* 47 */     setText(text);
/*    */   }
/*    */ }

/* Location:           C:\workspace\dognuts\dognuts\dognuts.jar
 * Qualified Name:     org.dognuts.gui.ChatTextArea
 * JD-Core Version:    0.6.0
 */